home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / xmsif.exe / XMSTEST.C < prev    next >
C/C++ Source or Header  |  1992-11-14  |  54KB  |  1,191 lines

  1. /***************************************************************************
  2. *   xmstest.c                                                              *
  3. *   MODULE:  XMSIF                                                         *
  4. *   OS:      DOS                                                           *
  5. *   VERSION: 1.2                                                           *
  6. *   DATE:    11/14/92                                                      *
  7. *                                                                          *
  8. *   Copyright (c) 1992 James W. Birdsall. All Rights Reserved.             *
  9. *                                                                          *
  10. *   Requires xmsif.h, testutil.h, and xmstest.h to compile.                *
  11. *   Compiles under Borland C++ 2.0, Turbo C 2.0, MSC 6.00A, MSC/C++ 7.0.   *
  12. *                                                                          *
  13. *   Regression test and example for XMSIF.                                 *
  14. *                                                                          *
  15. *   This file is part one of the regression tester and example for XMSIF.  *
  16. *   The other parts are named EMSTEST2.C and EMSTEST3.C. All three parts   *
  17. *   must be compiled and linked together along with the appropriate XMSIF  *
  18. *   library to produce the tester executable. This program compiles under  *
  19. *   tiny, small, medium, compact, large, and huge models.                  *
  20. *                                                                          *
  21. *   To use this tester: in general, just run it. Depending on what XMS     *
  22. *   driver you have, you may need to use the "-q" option. HIMEM.SYS does   *
  23. *   not require this option; QEMM 5.1* does; I don't know about other XMS  *
  24. *   drivers. If you haven't used it and should, or should use it and       *
  25. *   haven't, the tester can detect this and will abort with a message      *
  26. *   suggesting you do the opposite of whatever you did. For more detail on *
  27. *   what this option actually does, see below. The tester produces output  *
  28. *   on stdout. It performs 70+ tests, depending on the exact configuration *
  29. *   of your system, and parts of it run quite fast. If you want to read    *
  30. *   all the output, you should redirect the output to a file (but first    *
  31. *   you should probably run it straight to get an idea of how long it      *
  32. *   takes on your machine). If you just want to see whether the tests all  *
  33. *   pass, just run it -- if a test fails, execution aborts immediately.    *
  34. *                                                                          *
  35. *   Certain types of failure may cause XMSTEST to not deallocate memory    *
  36. *   that it has allocated. This should only occur if the library itself is *
  37. *   malfunctioning (which should never happen to you, only to me!) or if   *
  38. *   you are trying a different compiler or unsupported memory model and    *
  39. *   the compiler and library are therefore not communicating properly. It  *
  40. *   may also happen if you press control-break.                            *
  41. *                                                                          *
  42. *                                                                          *
  43. *   The actions XMSTEST takes may be broken down into two parts: EMB tests *
  44. *   and UMB tests. In the first part, it tests the XMM* functions which    *
  45. *   operate on extended memory blocks (EMBs). In the second part, it tests *
  46. *   the UMB* functions which operate on upper memory blocks (UMBs). Before *
  47. *   doing any of this, it tries to initialize XMSIF, which checks for the  *
  48. *   presence of an XMS driver, and aborts if there isn't one. Then it      *
  49. *   starts the first part, performing various preliminary tests on EMBs.   *
  50. *   If it determines that there isn't a large enough EMB free, it reports  *
  51. *   this and skips the copying function tests (tests of _XMMcopy() and     *
  52. *   _XMMicopy()), otherwise it performs the copying function tests. Then   *
  53. *   it starts the second part by trying to determine whether your system   *
  54. *   has UMBs. If it does not, it reports this fact and skips the rest of   *
  55. *   the UMB tests. If it does, it performs the rest of the UMB tests. If   *
  56. *   you see a message about "another broken system", that means that your  *
  57. *   XMS driver's support of UMBs is somewhat flaky, and the workarounds    *
  58. *   already built into XMSIF were unable to cover the problem. In this     *
  59. *   case, it will perform the rest of the UMB tests but is unable to check *
  60. *   that the functions actually did anything -- i.e. it can check the      *
  61. *   return code from the function, but cannot independently verify via     *
  62. *   other functions that the desired effect was actually achieved. See the *
  63. *   XMSIF documentation for a description of problems seen in the UMB      *
  64. *   support of various XMS drivers.                                        *
  65. *                                                                          *
  66. *   The "-q" option covers for some unusual behavior observed in QEMM      *
  67. *   5.1* which may also occur in other XMS drivers which provide EMS       *
  68. *   services as well. In QEMM's case, when extended memory is allocated,   *
  69. *   the total amount of XMS still available is decreased by the allocation *
  70. *   size rounded up to the nearest _16K_ (the EMS page size) instead of to *
  71. *   the nearest 1K (the XMS minimum allocation unit). HIMEM.SYS does not   *
  72. *   display this behavior. The "-q" option tells XMSTEST to expect a drop  *
  73. *   of a multiple of 16K after an allocation instead of a multiple of 1K.  *
  74. *   While XMSTEST can easily detect the difference, this option was added  *
  75. *   so that XMSTEST would know which multiple was expected and could       *
  76. *   detect incorrect drops more reliably.                                  *
  77. *                                                                          *
  78. *   The "-w" option covers for some different unusual behavior observed    *
  79. *   in DOS windows running under MS Windows 3.1 (it is not known whether   *
  80. *   Windows 3.0 does the same thing). In this case, when extended memory   *
  81. *   is allocated, the total amount of XMS still available is decreased by  *
  82. *   the allocation size rounded up to the nearest _4K_ (the 803/486 memory *
  83. *   management page size). The "-w" option tells XMSTEST to expect a drop  *
  84. *   of a multiple of 4K after an allocation instead of a multiple of 1K.   *
  85. *   While XMSTEST can easily detect the difference, this option was added  *
  86. *   so that XMSTEST would know which multiple was expected and could       *
  87. *   detect incorrect drops more reliably.                                  *
  88. *                                                                          *
  89. *                                                                          *
  90. *   Turbo C and older versions of Turbo C++ do not have the _fmemcmp() and *
  91. *   _fmemset() functions; I don't know about older versions of MSC. If     *
  92. *   your compiler does not have these functions, define the symbol         *
  93. *   NO_FFUNC and functions in this file will be used instead.              *
  94. *                                                                          *
  95. ***************************************************************************/
  96.  
  97. /*
  98. ** system includes <>
  99. */
  100.  
  101. #include <stdio.h>
  102. #include <stdlib.h>
  103. #include <dos.h>
  104. #include <string.h>
  105. #include <ctype.h>
  106.  
  107.  
  108. /*
  109. ** custom includes ""
  110. */
  111.  
  112. #include "xmsif.h"
  113. #include "xmstest.h"
  114.  
  115. #include "testutil.h"
  116.  
  117. /*
  118. ** local #defines
  119. */
  120.  
  121. /*
  122. ** misc: copyright strings, version macros, etc.
  123. */
  124.  
  125. /*
  126. ** typedefs
  127. */
  128.  
  129. /*
  130. ** global variables
  131. */
  132.  
  133. int testno = 1;                     /* number of test currently being done  */
  134. char *gblmsg = "";                  /* msg to be printed in test header     */
  135.  
  136. int qflag = 0;                      /* running QEMM or not?                 */
  137. int wflag = 0;                      /* running under Windows or not?        */
  138.  
  139.  
  140. /*
  141. ** static globals
  142. */
  143.  
  144. /*
  145. ** function prototypes
  146. */
  147.  
  148. /*
  149. ** fu